package com.hxtec.polaris.controller;

import com.hxtec.polaris.commons.api.vo.Result;
import com.hxtec.polaris.commons.dto.OrderInfoDto;
import com.hxtec.polaris.entity.ShopAddress;
import com.hxtec.polaris.entity.ShopOrder;
import com.hxtec.polaris.service.OrderService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.Map;

/**
 * @Describtion 订单相关
 * @Author yonyong
 * @Date 2019/11/27 9:24
 * @Version 1.0.0
 **/
@RestController
@RequestMapping(value = "order")
@CrossOrigin
@Api(value = "/order", tags = "订单相关")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @GetMapping("getOrder")
    public Object getOrder(Integer state, Integer pageNow, Integer rows){ return orderService.getOrder(state,pageNow,rows); }

    @PutMapping("cancelOrder")
    public Object cancelOrder(ShopOrder shopOrder){
        return orderService.cancelOrder(shopOrder);
    }

    @DeleteMapping("deleteOrder")
    public Object deleteOrder(ShopOrder shopOrder){
        return orderService.deleteOrder(shopOrder);
    }

    @PostMapping("pay")
    public Object payOrder(){
        return null;
    }

    @PostMapping("receive")
    public Object confirmReceive(){
        return null;
    }

    /**
     * 延时收货
     * @param shopOrder
     * @return
     */
    @PutMapping("extendedReceipt")
    public Object extendedReceipt(ShopOrder shopOrder){
        return orderService.extendedReceipt(shopOrder);
    }

    /**
     * 确认收货
     * @param shopOrder
     * @return
     */
    @PutMapping("confirmReceipt")
    public Object confirmReceipt(ShopOrder shopOrder){
        return orderService.confirmReceipt(shopOrder);
    }

    @PostMapping("rateOrder")
    public Object rateOrder(int id,int state,String content){
        return orderService.rateOrder(id,state,content);
    }

    @PostMapping("submitOrder")
    public Result<?> submitOrder(@RequestBody OrderInfoDto orderInfoDto) {
        Map<String,Object> map=orderService.submitOrder(orderInfoDto);
        return Result.ok(map);
    }
    @GetMapping("getPrice")
    public Object getPrice(int oid){ return orderService.getPrice(oid); }
}
